//
//  MultipleChoicePopUpVC.m
//  CreditHub
//
//  Created by chenglang on 2024/9/21.
//

#import "MultipleChoicePopUpVC.h"

@interface MultipleChoicePopUpVC ()<UIPickerViewDelegate,UIPickerViewDataSource>
@property (weak, nonatomic) IBOutlet UIPickerView *pickerView;
@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
@property (nonatomic, assign) NSInteger selectRow;
@end

@implementation MultipleChoicePopUpVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.pickerView.delegate = self;
    self.pickerView.dataSource = self;


}

- (IBAction)clickOk:(id)sender {
    __weak typeof(self) weakSelf = self;
    [self dismissViewControllerAnimated:YES completion:^{
        if(weakSelf.selectBlock){
            
            weakSelf.selectBlock(weakSelf.selectRow);
        }
    }];
}
- (IBAction)clickClose:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
#pragma mark - UIPickerView DataSource

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}


- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return self.dataSource.count;
}

#pragma mark - UIPickerView Delegate

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    pickerView.subviews[1].backgroundColor = UIColor.clearColor;
    return self.dataSource[row];
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    self.selectRow = row;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
